/* $RCSFile: ADNDynImport.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynImport.cs $
 * $log$
 * Revision 19 2010/10/02 14:01:49  christian.surieux
 *   Corrected a bug in allmost everyADNDyn file for PrimaryFieldVualue
 * Revision 6 2010/08/06 19:56:32  christian.surieux
 *   Added Log to All cs files
 */

/* Copyrights Christian Surieux 2010 */
/* Class ADNDynImport */
/* Date 2010-01-06 16:05:28Z */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynImport : DynEntity
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.import)
            {}

            public override Type DynType
            { get { return typeof(ADNDynImport); } }

            public override string DynTypename
            {   get{ return CrmStr.import;}}

            public override DynEntity Build()
            {   return new ADNDynImport();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynImport(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynImport(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynImport(w,PrimaryKeyValue);}
        }

        static ADNDynImport(){new Ftor();} 
        
        public override bool HasOwningBusinessUnitProperty
        { get { return true; } }
        
        public ADNDynImport() : base() { }
        
        public ADNDynImport(CRMWrapperBase w,string PrimaryFieldValue)
            : base(w,CrmStr.import)
        {
            if ( PrimaryFieldValue != string.Empty )
                name = PrimaryFieldValue;
        }
        
        public ADNDynImport(CRMWrapperBase w,Guid CrmId) : base(w,CrmStr.import,CrmId) { }
        
        public ADNDynImport(CRMWrapperBase w,InternalDynamicEntity e) : base(w,CrmStr.import,e,null,null) { }
        
        public ADNDynImport(CRMWrapperBase w,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(w,CrmStr.import,e,prop,s) { }
        
        public ADNDynImport(ResetWrapperHandler fn,string PrimaryFieldValue)
            : base(fn,CrmStr.import)
        {
            if ( PrimaryFieldValue != string.Empty )
                name = PrimaryFieldValue;
        }
        
        public ADNDynImport(ResetWrapperHandler fn,Guid CrmId) : base(fn,CrmStr.import,CrmId) { }
        
        public ADNDynImport(ResetWrapperHandler fn,InternalDynamicEntity e) : base(fn,CrmStr.import,e,null,null) { }
        
        public ADNDynImport(ResetWrapperHandler fn,InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s) : base(fn,CrmStr.import,e,prop,s) { }

        /* Properties */

        [CrmDynAttribute(CrmStr.import)]
        public Guid importid
        {
            get
            { return KeyPropertyValue(CrmStr.importid); }
            set
            { AddKeyProperty(CrmStr.importid,value); }
        }

        protected override void SetCrmIdProperty(Guid crmId)
        {
            if ( !dicProperty.ContainsKey(CrmStr.importid) || KeyPropertyValue(CrmStr.importid) != crmId )
                importid = crmId;
        }
        public override Guid PrimaryKeyGuidValue
        {
            get
            { return importid; }
            set { importid = value; }
        }
        
        public override string PrimaryFieldName
        {
            get
            { return CrmStr.name; }
            set
            {}
        }

        /// <summary>
        /// Value contained in the PrimaryField for the DynEntity or empty if no PrimaryField
        /// </summary>
        public override string PrimaryFieldStringValue
        {
            get
            {
                return name;
            }
            set
            {
                name =   value;
            }
        }

        [CrmDynAttribute(CrmStr.import)]
        public string emailaddress
        {
            get
            { return StringPropertyValue(CrmStr.emailaddress); }
            set
            { AddStringProperty(CrmStr.emailaddress,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public bool isimport
        {
            get
            { return BooleanPropertyValue(CrmStr.isimport); }
            set
            { AddBooleanProperty(CrmStr.isimport,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public int modecode
        {
            get
            { return PicklistPropertyIntValue(CrmStr.modecode); }
            set
            { AddPicklistProperty(CrmStr.modecode,value); }
        }

        public string modecodeLabel
        {
            get
            { return PicklistPropertyLabelValue(CrmStr.modecode); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public override string name
        {
            get
            { return StringPropertyValue(CrmStr.name); }
            set
            { AddStringProperty(CrmStr.name,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public Guid owningbusinessunit
        {
            get
            { return LookupPropertyValue(CrmStr.owningbusinessunit); }
            set
            { AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public Guid owninguser
        {
            get
            { return LookupPropertyValue(CrmStr.owninguser); }
            set
            { AddLookupProperty(CrmStr.owninguser,CrmStr.systemuser,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public bool sendnotification
        {
            get
            { return BooleanPropertyValue(CrmStr.sendnotification); }
            set
            { AddBooleanProperty(CrmStr.sendnotification,value); }
        }

        [CrmDynAttribute(CrmStr.import)]
        public int sequence
        {
            get
            { return NumberPropertyValue(CrmStr.sequence); }
            set
            { AddNumberProperty(CrmStr.sequence,value); }
        }
    }
}